package com.szxy.hotel.mapper;

import com.szxy.hotel.entity.Admin;
import org.apache.ibatis.annotations.*;

@Mapper
public interface AdminMapper {

    @Select("select * from admin where user_name = #{userAccount}")
    @ResultMap("AdminResultMap")
    Admin findByuserAccount(@Param("userAccount") String userAccount);

    @Insert("insert into admin (user_name,user_password,user_type,user_question,user_answer,user_statusid) values(#{userAccount},#{userPassword},#{selectType},#{selectHobby},#{userAnswer},#{userStatusid})")
    @ResultMap("AdminResultMap")
    int doRegist(@Param("userAccount") String userAccount,@Param("userPassword") String userPassword,@Param("userAnswer") String userAnswer,@Param("selectType") String selectType,@Param("selectHobby") String selectHobby,@Param("userStatusid") int userStatusid);

    @Update("update admin set user_password = #{userPassword} where user_name = #{userName}")
    @ResultMap("AdminResultMap")
    int doUpdatepassword(@Param("userName") String userName,@Param("userPassword") String userPassword);

    @Update("update admin set user_statusid = 1 where user_name = #{username}")
    @ResultMap("AdminResultMap")
    int doDecode(@Param("username") String username);

    @Update("update admin set user_statusid = 0 where user_name = #{uname}")
    @ResultMap("AdminResultMap")
    int overDecode(@Param("uname") String uname);
}